class KthLargest {
public:
    int K;
    priority_queue<int,vector<int>,greater<int>> que;
    KthLargest(int k, vector<int>& nums) {
        for(int i=0;i<nums.size();i++){
            que.push(nums[i]);
            if(que.size()>k){que.pop();}
        }
        K=k;
    }
    
    int add(int val) {
        que.push(val);
        if(que.size()>K){que.pop();}
        return que.top();
    }
};




/**
 * Your KthLargest object will be instantiated and called as such:
 * KthLargest* obj = new KthLargest(k, nums);
 * int param_1 = obj->add(val);
 */